-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #14392 FN knownConditionTrueFalse (assigning function call result) #8118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| ASSERT_EQUALS("", errout_str()); | ||
|
|
||
| check("struct S {\n" // #14392 | ||
| " bool g() const { return m; }\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make sure it doesnt warn when doing bool g() const { return true; }.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, this is a different warning.
|
|
This looks like a true positive: cppcheck/externals/tinyxml2/tinyxml2.cpp Line 1133 in bf76975
We don't catch this instance yet: Line 2927 in bf76975
|
| " }\n" | ||
| " return false;\n" | ||
| "}\n"); | ||
| ASSERT_EQUALS("[test.cpp:6:12] -> [test.cpp:7:21]: (style) Condition 's.g()' is always true [knownConditionTrueFalse]\n", errout_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems unfortunate to say that "Condition" is always true. The RHS in a assignment is not a "Condition".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if g() returns an int instead? That is not "true" or "false".



No description provided.